// 正常形态
function test(a) {
    let b = a;
    b += 1;
    b += 2;
    b += 3;
    b += 4;
    return a + b
}

// 乱序形态
//（这里比较简单,在很多加密网站上case 后面往往不是数字或字符串,而是类似 YFp[15][45][4]这样的对象，相当恶心）
function test1(a) {
    let arr = [1, 2, 3, 4, 5, 6];
    let b = 0;
    for (let i = 0; i < arr.length; i++) {
        switch (arr[i]) {
            case 4:
                b += 3;
                break;
            case 2:
                b += 1;
                break;
            case 1:
                b = a;
                break;
            case 3:
                b += 2;
                break;
            case 6:
                return a + b
            case 5:
                b += 4;
                break;
        }
    }
}

// 压缩状态
function test2(a) {
    let b, c, d, e, f;
    return f = (e = (d = (c = (b = a, b + 1), b + 2), b + 3), b + 4), e + f;
}

// 结果都是30 但是test1看着费劲
console.log(test1(10));
console.log(test(10));
console.log(test2(10));


// jsvmp
function jsvmp_code1() {
    let a = '丽丽'
    let b = '菲菲'
    let c = '莹莹'
    let d = a + b
    let e = c + d

    console.log({a, b, c, d, e})
}

function jsvmp_code2(_stack) {
    let register;   // 这个就当做是问号的存储位置
    let variable = {};   // 这个就当做是var变量的存储位置。由于没有其他声明方式的存在，所就不写其他的了
    for (let i = 0; i < _stack.length; i++) {
        instruct = _stack[i][0];
        left = _stack[i][1];
        right = _stack[i][2];
        if (instruct === 3) {
            variable[right] = ''
        }
        if (instruct === 1) {
            if (right === '?') {
                variable[left] = register
            } else {
                variable[left] = right
            }
        }
        if (instruct === 2) {
            register = variable[left] + variable[right]
        }
    }
    console.log(variable)
}

jsvmp_code1()
jsvmp_code2([[3, 'var', 'a'], [1, 'a', '丽丽'],[3, 'var', 'b'],[1, 'b', '菲菲'],[3, 'var', 'c'],[1, 'c', '莹莹'],[3, 'var', 'd'],[2, 'a', 'b'], [1, 'd', '?'], [3, 'var', 'e'], [2, 'd', 'c'], [1, 'e', '?'],])